package com.freejava.test_rocketmq.service;

import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

/**
 * 一个简单的消费者
 */
@Service
@RocketMQMessageListener(topic="testOneTopic1", consumerGroup = "comsumer_group_registeredOne", selectorExpression = "register")
public class SimpleMessageListener implements RocketMQListener<String> {
    // 引入日志类
    private static final Logger logger = LoggerFactory.getLogger(SimpleMessageListener.class);

    @Override
    public void onMessage(String msg) {
        logger.info("获取到消息了，消息是 : {}", msg);
        // 其他业务代码
    }
}
